home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5465 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: (void(far *)()) 0
  5. Date: 8 Feb 96 19:18:45 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.823807125@rscernix>
  8. References: <341998718.10858110@magnet.at> <31165B9D.398E@imsisoft.com> <4f66c0$cn0@solutions.solon.com> <3118F813.41BF@imsisoft.com>
  9. NNTP-Posting-Host: hpl3sn02.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <3118F813.41BF@imsisoft.com> Victor Bazarov <vbazarov@imsisoft.com> writes:
  13.  
  14. >As I undestood, this "may produce different results":
  15. >
  16. >typedef void (far *pVOIDVOID)();
  17. >int zero = 0;
  18. >pVOIDVOID funky;
  19. >funky = (void(far *)()) zero;
  20. >
  21. >than
  22. >
  23. >typedef void (far *pVOIDVOID)();
  24. >pVOIDVOID funky;
  25. >funky = (void(far *)()) 0;
  26.  
  27. Both of them may produce _any_ results, because of the presence of "far",
  28. which invokes undefined behaviour (and requires a diagnostic).  
  29.  
  30. If we remove it (there is absolutely no need for it in this discussion), 
  31. the first example produces an implementation-defined result, while the
  32. second produces a well defined result.
  33.  
  34. BTW, I'd rather write:
  35.  
  36.     funky = 0; /* Not really, funky = NULL; is my favourite */
  37.  
  38. but if you insist on the cast, make it (pVOIDVOID) 0.
  39.  
  40. Dan
  41. --
  42. Dan Pop
  43. CERN, CN Division
  44. Email: danpop@mail.cern.ch 
  45. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  46.